<template>
<view-box style="background:#F3F6F7;">
<div class="address-search">
      <router-link to="/search" class="search-div">
        <i class="search-icon iconfont icon-sousuo" style="font-size: 20px;"></i>
        <p class="search-String">天南山</p>
      </router-link>
    </div>
    <div style="height: 46px;"></div>
    <div class="co-laou" v-for="(item, index) in items" v-if="identity === '1'" :key="index" @click="dianclick(item.id)">
        <div class="co-lib">
            <div class="co-dilkp">
                <p style="font-size:15px;color:#000;font-weight: 600;">{{item.position_name}}</p>
                <p style="font-size:13px;color:#BABABA;">{{item.city}} | {{item.age_limit}} | {{item.nature}}</p>
            </div>
            <div class="co-dilk">
                <p style="font-size:15px;color:#32B6C6;font-weight: 600;">{{item.pay}}</p>
                <p style="font-size:13px;color:#BABABA;">{{item.created_at | formatDate}}</p>
            </div>
        </div>
        <div class="co-bott-om">
           <div class="work-job-lj">
                <p style="color: #ff0000;font-weight: 600;width:100%;">
                  <img style="width:66px;height:66px;border-radius: 7px;" :src="$apiUrl + '/storage/' + item.company_info.logo" alt="">
                </p>
            </div>
            <div class="work-job-cl" >
                <p class="job-pol-col" style="font-size:13px;color:#000;font-weight: 0;">{{item.company_info.cname}}</p>
                <p class="job-pol-col" style="font-size:13px;color:#BABABA;font-weight: 0;">{{item.company_info.renshu}} | {{item.company_info.hangye}}</p>
            </div>
        </div>
     </div>
      <div class="co-laou" v-for="(item, index) in items" :key="index" @click="$router.push('/previewLouw?id=' + item.user_id)" v-if="identity === '2' && item.basic !== null">
        <div class="co-lib">
            <div class="co-dilkp">
                <p style="font-size:15px;color:#000;font-weight: 600;" v-if="item.basic === null">未知职位</p>
                <p style="font-size:15px;color:#000;font-weight: 600;" v-if="item.basic !== null">{{item.basic.company}}</p>
                <p style="font-size:13px;color:#BABABA;">{{item.basic.city}} | {{birth - item.basic.start_work_time}}年 | {{item.work_number_count}}段工作经验</p>
            </div>
            <div class="co-dilk">
                <p style="font-size:15px;color:#32B6C6;font-weight: 600;" v-if="item.basic !== null && item.basic.is_look_annual_salary === 1">{{item.basic.annual_salary}}</p>
                <p style="font-size:15px;color:#32B6C6;font-weight: 600;" v-if="item.basic !== null && item.basic.is_look_annual_salary === 0">保密</p>
                <p style="font-size:13px;color:#BABABA;">{{item.created_at | formatDate}}</p>
            </div>
        </div>
        <div class="co-bott-om">
           <div class="work-job-lj">
                <p style="color: #ff0000;font-weight: 600;width:100%;"><img style="width:66px;height:66px;" :src="item.user.avatar" alt=""></p>
            </div>
            <div class="work-job-cl" >
                <p class="job-pol-col" style="font-size:13px;color:#000;font-weight: 0;">{{item.basic.true_name}}</p>
                <p class="job-pol-col" style="font-size:13px;color:#BABABA;font-weight: 0;">{{item.basic.now_status}}</p>
            </div>
        </div>
     </div>
    
         <infinite-loading @infinite="infiniteHandler" ref="infiniteLoading">
            <load-more slot="no-more" :show-loading="false" tip="到底了" background-color="#fbf9fe"></load-more>
            <empty slot="no-results" tips="暂时没有相关内容"></empty>
        </infinite-loading>
</view-box>
</template>
<script>
import bMenu from '../components/bottom_menu'
import { ViewBox, Box, Flexbox, FlexboxItem, Divider } from 'vux'
import { formatDate } from '../../utils/index.js'

export default {
  components: {
    ViewBox,
    Box,
    bMenu,
    Flexbox,
    FlexboxItem,
    Divider
  },
  data () {
    return {
      entrance: {
        identity: 0,
        motto: null,
        position: null,
        sex: 0
      },
      items: [],
      identity: 0,
      postPlg: ''
    }
  },
  computed: {
    birth: function () {
      let mydate = new Date()
      let newdate = mydate.getFullYear()
      console.log(newdate)
      return newdate
    }
  },
  filters: {
    formatDate (time) {
      var date = new Date(time)
      return formatDate(date, 'yyyy-MM-dd')
    }
  },
  mounted () {
    this.identity = localStorage.getItem('identity')
    this.postPlg = this.$route.query.postPlg
  },
  methods: {
    dianclick (id) {
      localStorage.setItem('interview', id)
      this.$router.push({path: '/Details/?rid=' + id})
    },
    _getentrance () {
      this.$http.get('/entrance').then((response) => {
        this.entrance = response.data.data
        console.log(this.entrance)
      }).catch((error) => {
        console.log(error)
      })
    },
    infiniteHandler ($state) {
      if (this.identity === '1') {
        this.$http.get('/zhiwei', {
          params: {
            order: String(this.$route.query.rouiy),
            page: this.items.length / 20 + 1,
            page_size: 20
          }
        }).then((response) => {
          if (response.data.data.length) {
            console.log(1212)
            this.items = this.items.concat(response.data.data)
            $state.loaded()
            if (!response.data.next_page_url) {
              $state.complete()
            }
          } else {
            $state.complete()
          }
        })
      } else if (this.identity === '2') {
        this.$http.get('/talentsRecommend', {
          params: {
            order: String(this.$route.query.rouiy),
            page: this.items.length / 20 + 1,
            page_size: 20
          }
        }).then((response) => {
          if (response.data.data.length) {
            console.log(1212)
            this.items = this.items.concat(response.data.data)
            $state.loaded()
            if (!response.data.next_page_url) {
              $state.complete()
            }
          } else {
            $state.complete()
          }
        })
      }
    }
  }
}
</script>
<style scoped>
.border-ter{
    width: 82%;
    /* border-bottom: 1px solid #f4f4f4; */
    margin-left: 4%;
    list-style: none;
    padding-top: 10px;
    padding-bottom: 10px;
}
.font-cong{
    font-size:16px;
    font-weight: 600px;
}
  .address-search {
    height: 50px;
    width: 100%;
    font-size: 16px;
    position: fixed;
    z-index: 999;
    top: 0;
    display: flex;
    background-color: #fff;
  }
  .address-div {
    width: 25%;
    padding-left: 5px;
    height: 50px;
    line-height: 50px;
    display: flex;
    -webkit-box-pack: center;
    justify-content: center;
  }
  .address-icon {
    color: #595959;
    margin-left: 6px;
    padding-right: 6px;
  }
  .address-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #878787;
  }
  .xaddress {
    display: none;
  }
  .search-div {
    width: 94%;
    line-height: 30px;
    display: flex;
    height: 30px;
    margin-top: 10px;
    margin-left: 3%;
    background-color: #f2f2f2;
    border-radius: 20px;
  }
  .search-icon {
    color: #8e8e8e;
    margin-left: 5%;
    font-size: 20px;
  }
  .search-String {
    color: #bebebe;
    margin-left: 5%;
    font-size: 15px;
  }
.co-laou{
width: 92%;
margin-left: 4%;
background: #fff;
opacity: 0.8;
height: auto;
margin-top: 10px;
border-radius: 7px;
}
.co-lib{
    display: flex;
    width: 92%;
    margin-left: 4%;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding-top: 20px;
    padding-bottom: 10px;
}
 .co-dilk{
    width: 40%;
    text-align: right;
  }
  .co-dilkp{
    width: 60%;
  }
  .co-bott-om{
  display: flex;
  width: 92%;
  margin-left: 4%;
  padding-top: 5px;
  padding-bottom: 5px;
}
.work-job-lj {
    width: 25%;
    display: flex;
    align-items: center;
}
.work-job-lj p{
    font-size: 15px;

}
.work-job-cl{
  width: 75%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}
.job-pol-col{
  width: 100%;
  font-weight: 600;
}
.work-job-cl p{
  text-align: left;
  font-size: 15px;
}
</style>